package edu.cibertec.sicsolutions.vfs.domain.votacion;

import org.apache.log4j.Logger;

import edu.cibertec.sicsolutions.exception.DaoException;
import edu.cibertec.sicsolutions.exception.DomainException;
import edu.cibertec.sicsolutions.vfs.dao.votacion.ElectorVirtualDao;
import edu.cibertec.sicsolutions.vfs.spring.SpringContext;

import java.io.Serializable;
import java.util.Map;

/**
 * Domain Object of table ELECTOR_VIRTUAL 
 * @author enrique.vargas
 *
 */
public class ElectorVirtual implements Serializable {

	private static final Logger log = Logger.getLogger(ElectorVirtual.class);
	private static final ElectorVirtualDao electorVirtualDao = (ElectorVirtualDao)SpringContext.get(ElectorVirtualDao.class);	
 
	
	public ElectorVirtual(){
	}
	
	public ElectorVirtual(Integer codigo){
		this.codigo = codigo;
	}
	
	/**
	 * Column: CODIGO, DataType: int
	 */
	private Integer codigo;
	/**
	 * Column: LOGIN, DataType: Char
	 */
	private String login;
	/**
	 * Column: PASSWORD, DataType: varchar
	 */
	private String password;
	/**
	 * Column: CODIGO_EMPADRONADO, DataType: int
	 */
	private Integer codigoEmpadronado;


	public Integer getCodigo(){
		return codigo;
	}
	public void setCodigo(Integer codigo){
		this.codigo = codigo;
	}
	public String getLogin() {
		return login;
	}
	public void setLogin(String login) {
		this.login = login;
	}
	public String getPassword(){
		return password;
	}
	public void setPassword(String password){
		this.password = password;
	}
	public Integer getCodigoEmpadronado(){
		return codigoEmpadronado;
	}
	public void setCodigoEmpadronado(Integer codigoEmpadronado){
		this.codigoEmpadronado = codigoEmpadronado;
	}

	/**
	 * Get Object of Data Base By PK	 
	 * @param electorVirtual
	 * @return
	 * @throws DomainException
	 */
	public static ElectorVirtual getElectorVirtualByPk(ElectorVirtual electorVirtual) throws DomainException{
		try{
			return electorVirtualDao.getElectorVirtualByPk(electorVirtual);
		} catch (DaoException e) {
			log.error(e.getMessage(), e);
			throw new DomainException(e.getMessage(), e);
		} catch (Exception e){
			log.error(e.getMessage(), e);
			throw new DomainException(e.getMessage(), e);
		}		
	}
	
	/**
	 * Save Object
	 * @param electorVirtual
	 * @return
	 * @throws DomainException
	 */	
	public static void insertElectorVirtual (ElectorVirtual electorVirtual) throws DomainException{
		try{
			electorVirtualDao.insertElectorVirtual(electorVirtual);
		} catch (DaoException e) {
			log.error(e.getMessage(), e);
			throw new DomainException(e.getMessage(), e);
		} catch (Exception e){
			log.error(e.getMessage(), e);
			throw new DomainException(e.getMessage(), e);
		}		
	}
	
	/**
	 * Update Object 
	 * @param electorVirtual
	 * @return
	 * @throws DomainException
	 */
	public static void updateElectorVirtual (ElectorVirtual electorVirtual) throws DomainException{		
		try{
			electorVirtualDao.updateElectorVirtual(electorVirtual);
		} catch (DaoException e) {
			log.error(e.getMessage(), e);
			throw new DomainException(e.getMessage(), e);
		} catch (Exception e){
			log.error(e.getMessage(), e);
			throw new DomainException(e.getMessage(), e);
		}
	}
	
	/**
	 * Update Object 
	 * @param electorVirtual
	 * @return
	 * @throws DomainException
	 */
	public static void updateElectorVirtualByMap (Map map) throws DomainException{		
		try{
			electorVirtualDao.updateElectorVirtualByMap(map);
		} catch (DaoException e) {
			log.error(e.getMessage(), e);
			throw new DomainException(e.getMessage(), e);
		} catch (Exception e){
			log.error(e.getMessage(), e);
			throw new DomainException(e.getMessage(), e);
		}
	}
	
	/**
	 * Delete Object	 
	 * @param electorVirtual
	 * @return
	 * @throws DomainException
	 */
	public static void deleteElectorVirtualByPk(ElectorVirtual electorVirtual) throws DomainException{		
		try{
			electorVirtualDao.deleteElectorVirtualByPk(electorVirtual);
		} catch (DaoException e) {
			log.error(e.getMessage(), e);
			throw new DomainException(e.getMessage(), e);
		} catch (Exception e){
			log.error(e.getMessage(), e);
			throw new DomainException(e.getMessage(), e);
		}
	}
	
	/**
	 * Find Object By Filters
	 * @param electorVirtual
	 * @return
	 * @throws DomainException
	 */
	public static ElectorVirtual[] findElectorVirtualByClass(ElectorVirtual electorVirtual) throws DomainException{		
		try{
			return electorVirtualDao.findElectorVirtualByClass(electorVirtual);
		} catch (DaoException e) {
			log.error(e.getMessage(), e);
			throw new DomainException(e.getMessage(), e);
		} catch (Exception e){
			log.error(e.getMessage(), e);
			throw new DomainException(e.getMessage(), e);
		}
	}

 
}